using namespace std;
#include <vector>

class Solution
{
public:
    static vector<int> countBits(int n)
    {
        vector<int> ans(n+1);
        for(int i=0; i<=n; i++)
        {
            int count = 0;
            int x = i;
            while(x)
            {
                x &= x-1;
                count++;
            }
            ans[i]=count;
        }
        return ans;
    }
};